package com.pan.clean;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TxtCleaner implements WordCleaner{

  @Override
  public List<String> cleanUnnessarySpace(List<String> lines) {
    if (CollectionUtils.isEmpty(lines)) {
      return lines;
    }
    List<String> cleanSentences = new ArrayList<>();
    Iterator<String> iterator = lines.iterator();
    while (iterator.hasNext()){
        String line=iterator.next();
        if( StringUtils.isBlank(line)){
          iterator.remove();
          continue;
        }
        //替换中文全角空格
      String lineTrim = line.trim();
      cleanSentences.add(lineTrim);
    }
    return cleanSentences;
  }



  public static void main(String[] args) {
    List<String> spaceSentence = new ArrayList<>();
    spaceSentence.add("　　目录");
    Iterator<String> iterator = spaceSentence.iterator();
    while (iterator.hasNext()){
      String line = iterator.next();
      line.trim().replace("　","");
    }

    System.out.println(spaceSentence.get(0).replace("　","$"));

  }
}
